library(tidyverse)
## -- Attaching packages ----------------------------------------------------------- tidyverse 1.2.1 --
## v ggplot2 3.0.0 v purrr 0.3.3
## v tibble 3.0.0 v dplyr 0.8.5
## v tidyr 1.0.2 v stringr 1.3.1
## v readr 1.1.1 v forcats 0.3.0
## Warning: package 'tibble' was built under R version 3.5.3
## Warning: package 'tidyr' was built under R version 3.5.3
## Warning: package 'purrr' was built under R version 3.5.3
## Warning: package 'dplyr' was built under R version 3.5.3
## -- Conflicts -------------------------------------------------------------- tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(dplyr)
library(ggplot2)
library(plotly)
## Warning: package 'plotly' was built under R version 3.5.3
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
** LOADING ORIGINAL DATA SETS HERE**
nyt <- read.csv("https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-counties.csv", stringsAsFactors = FALSE)
nyt$date <- as.Date(nyt$date, format= "%Y-%m-%d")
theme_set(theme_minimal())
allegheny <- nyt%>%
filter(county == "Allegheny", state == "Pennsylvania")
a <- ggplot(allegheny, aes(date)) +
geom_line(aes(y = cases, colour = "Total Cases")) +
geom_line(aes(y = deaths, colour = "Total Deaths"))+
theme_minimal()+
scale_x_date(date_breaks = "1 week", date_labels = "%b %d")+
ggtitle("Cases and Deaths in Allegheny County")
ggplotly(a)
jefferson <- nyt%>%
filter(county == "Jefferson", state == "Alabama")
j <- ggplot(jefferson, aes(date)) +
geom_line(aes(y = cases, colour = "Total Cases")) +
geom_line(aes(y = deaths, colour = "Total Deaths"))+
theme_minimal()+
scale_x_date(date_breaks = "1 week", date_labels = "%b %d")+
ggtitle("Cases and Deaths in Jefferson County")
ggplotly(j)
miamidade <- nyt%>%
filter(county == "Miami-Dade", state == "Florida")
m <- ggplot(miamidade, aes(date)) +
geom_line(aes(y = cases, colour = "Total Cases")) +
geom_line(aes(y = deaths, colour = "Total Deaths"))+
theme_minimal()+
scale_x_date(date_breaks = "1 week", date_labels = "%b %d")+
ggtitle("Cases and Deaths in Miami-Dade County")
ggplotly(m)
broward <- nyt%>%
filter(county == "Broward", state == "Florida")
b <- ggplot(broward, aes(date)) +
geom_line(aes(y = cases, colour = "Total Cases")) +
geom_line(aes(y = deaths, colour = "Total Deaths"))+
theme_minimal()+
scale_x_date(date_breaks = "1 week", date_labels = "%b %d")+
ggtitle("Cases and Deaths in Broward County")
ggplotly(b)
suffolk <- nyt%>%
filter(county == "Suffolk", state == "Massachusetts")
s <- ggplot(suffolk, aes(date)) +
geom_line(aes(y = cases, colour = "Total Cases")) +
geom_line(aes(y = deaths, colour = "Total Deaths"))+
theme_minimal()+
scale_x_date(date_breaks = "1 week", date_labels = "%b %d")+
ggtitle("Cases and Deaths in Suffolk County")
ggplotly(s)